/*
 * Alvin Baldemeca
 * TCSS 305 - Spring 2012
 * Assignment 4 Power Paint
 */

package gui.actions.paint;

import java.awt.Color;
//import java.awt.Graphics;
//import java.awt.Graphics2D;
//import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
//import java.util.Arrays;

import javax.swing.AbstractAction;
import javax.swing.Action;
//import javax.swing.Icon;
//import javax.swing.ImageIcon;
import javax.swing.JColorChooser;

import view.container.TetrisPaintPanel;

/**
 * The action to be attached to the color tool in the Power Paint program.
 * @author Alvin Baldemeca
 * @version 5/10/2012
 */
@SuppressWarnings("serial")
public class ColorAction extends AbstractAction
{
  
  /**
   * The color chooser for the color tool.
   */
  private static final JColorChooser COLOR_CHOOSER = new JColorChooser();
  
  /**
   * The panel to perform the action to.
   */
  private final TetrisPaintPanel my_panel;
  
  /**
   * Creates an action when the color tool is selected.
   * @param the_panel the panel that the color tool will be used on
   */
  public ColorAction(final TetrisPaintPanel the_panel) 
  {
    super("Color");
    my_panel = the_panel;
    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    putValue(Action.SELECTED_KEY, false);
    //my_color_chooser = 
  }

  @Override
  public void actionPerformed(final ActionEvent the_event) 
  {
    @SuppressWarnings("static-access")
    final Color passcolor = COLOR_CHOOSER.showDialog(my_panel, 
                      "Power Paint Color Chooser", Color.BLACK);    
    my_panel.selectColor(passcolor);
  }
}
